package com.tyk.bookstore.back.product.service.impl;

import com.tyk.bookstore.back.product.model.entity.BookStatisticDo;
import com.tyk.bookstore.back.product.model.query.Statistic4TaskUpdateQuery;
import com.tyk.bookstore.back.product.repository.BookStatisticRepository;
import com.tyk.bookstore.back.product.service.BookStatisticApiService;
import com.tyk.bookstore.back.product.util.MapStructProduct;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author tyk
 * @description BookStatisticApiServiceImpl
 */
@Service
@RequiredArgsConstructor
public class BookStatisticApiServiceImpl implements BookStatisticApiService {

    private final BookStatisticRepository statisticRepository;
    private final MapStructProduct mapStructProduct;

    @Override
    public void updateStatistic(List<Statistic4TaskUpdateQuery> qs) {
        List<BookStatisticDo> doList = mapStructProduct.toBookStatisticDoList(qs);
        statisticRepository.updateBatch(doList);
    }
}
